-
Notifications
You must be signed in to change notification settings - Fork 372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: support lg templates cross-file copy during Visual Editor copy / paste #2236
Conversation
@zhixzhan I need a new LG api whose interface is const createLgTemplate = (templateName: string, templateBody: string, templateParams?: any[]) => Promise<string>; // returns either the new template name or the whole template Do you have any idea on that? |
@cwhitten this PR will fix the problem in your 'Move' PR that moving SendActivity to new dialog will lose lg string. Current version works but the value of 'prompt' field in SendActivity will be the lg body string. // Action to be moved
{
$type: 'SendActivity',
activity: '${bfdactivity-1234()}' // the real content is '- hello'
}
// Action will appear in new dialog
{
$type: 'SendActivity',
activity: '- hello'
} I will solve that problem when lg api is ready. |
I see, this new api would return plain string template content without any reference. I'm not sure is it possible to convert deep nested lg template to plain string. I think about another solution is restrict composer created bot's lg reference structure:
if we apply this rule, we could maintain resource as usual without worry about buggy deep copy. |
@zhixzhan I used the |
Description
The old copy logic relied on a
copyLgTemplate
api provided by @zhixzhan , however, as reported in a recent issue #2207 , after lg templates were saved in separated files, it's not capable for cross-file copy behavior anymore.In this PR, I made a refactoring on the copy-paste flow to make the copy of actions independent from lg file structure and lg operation api.
Comparasion
Compared to the old solution that having a heavy 'paste' logic and external api dependency (
copyLgTemplate
):The new solution is more similar to a real clipboard in which copied/cut actions keep real lg text:
The most significant difference here is when does it handle lg template references.
paste
; it's buggy if the source actions were deleted before they were pasted.'${bfdactivity-1234}'
string will be copied as its real value'hello'
(lgTemplate.body)'hello'
will be transformed to a reference again by the apicreateLgTemplate
Benefits
Todos in the future:
paste
as described above (need a new createLgTemplate api @zhixzhan )ObiEditor.tsx
is exploding, consider to extract copy/paste logic out of it.Task Item
closes #2207
closes #2210
Screenshots